package com.woniuxy.oa.entity;

import java.util.List;

public class PageMsg {
	//当前页
	private int pageIndex;
	//页大小
	private int pageSize;
	//总页数
	private int pageTotal;
	//总记录条数
	private int recordTotal;
	//页开始展示的页码
	private int pageBegin;
	//页结束的页码
	private int pageEnd;
	//员工信息
	private List<EmployeeMsg> employeeMsgs;
	
	
	
	public int getPageBegin() {
		return pageBegin;
	}
	public int getPageEnd() {
		return pageEnd;
	}
	public List<EmployeeMsg> getEmployeeMsgs() {
		return employeeMsgs;
	}
	public void setEmployeeMsgs(List<EmployeeMsg> employeeMsgs) {
		this.employeeMsgs = employeeMsgs;
	}
	public int getPageIndex() {
		return pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getPageTotal() {
		return recordTotal%pageSize==0?recordTotal/pageSize:recordTotal/pageSize+1;
	}
	public void setPageTotal(int pageTotal) {
		this.pageTotal =pageTotal;
	}
	public int getRecordTotal() {
		return recordTotal;
	}
	public void setRecordTotal(int recordTotal) {
		this.recordTotal = recordTotal;
	}
	
	@Override
	public String toString() {
		return "PageMsg [pageIndex=" + pageIndex + ", pageSize=" + pageSize + ", pageTotal=" + pageTotal
				+ ", recordTotal=" + recordTotal + ", pageBegin=" + pageBegin + ", pageEnd=" + pageEnd
				+ ", employeeMsgs=" + employeeMsgs + "]";
	}
	public PageMsg(int pageIndex, int pageSize, int pageTotal, int recordTotal, int pageBegin, int pageEnd) {
		super();
		this.pageIndex = pageIndex;
		this.pageSize = pageSize;
		this.pageTotal = pageTotal;
		this.recordTotal = recordTotal;
		this.pageBegin = pageBegin;
		this.pageEnd = pageEnd;
	}
	public PageMsg() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	

	public void setPageBeginAndPageEnd() {
		//总页数小于10，页码从1到最后一页
		if(pageTotal<=10) {
			pageBegin=1;
			pageEnd=getPageTotal();
		}else if(pageIndex-5<1) {//当前页-5小于一，就展示前十页
			pageBegin=1;
			pageEnd=10;
		}else if(pageIndex+4>getPageTotal()){//当前页+4大于总页数，展示总页数及其前9页
			pageEnd=pageTotal;
			pageBegin=getPageTotal()-9;
		}else {//中间部分展示当前页的前5页到后4页
			pageBegin=pageIndex-5;
			pageEnd=pageIndex+4;
		}
		
	}
	
	
	
	
}
